<template>
    <div class="subheadings">
        {{ props.name }}
        <el-button type="primary" link v-if="tableData.length&&tableData.length>3" @click="showMore = !showMore">
            {{ showMore ? '收起':'展开' }} 
            <el-icon><ArrowDown v-if="!showMore" /><ArrowUp v-if="showMore" /></el-icon>
        </el-button>
    </div>
    <div class="assy">
        <el-table :data="collapsibleTableData">
            <el-table-column prop="province" label="省（直辖市）" align="center" />
            <el-table-column prop="province" label="数量" align="center">
                <template #default="scope">
                    <span style="color: #46FFFF;">{{scope.row.earthquakeNum}}</span>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script setup>
const props = defineProps({
  name: String,
  tableData:{
    default: [],
    type: Array,
  }
})
const data = reactive({
    showMore: false,//展开收起
})
const { showMore } = toRefs(data)
const { tableData } = toRefs(props)
const collapsibleTableData = computed(() => (data.showMore ? tableData.value : tableData.value.slice(0, 3)));

</script>
<style scoped lang="scss">
.subheadings{
    width: 450px;
    height: 105px;
    background-size: 100% 100%;
    background-image: url(/src/assets/images/common/bg_little_title.png);
    margin: 0 auto;
    color: #E4F5FF;
    font-size: 22px;
    font-family: Source Han Sans;
    font-weight: 500;
    line-height: 80px;
    text-align: left;
    box-sizing: border-box;
    padding-left: 40px;
    .el-button--primary{
        background: transparent !important;
        border: none !important;
        float: right;
        margin-top: 24px;
        color: #46FFFF !important;
        font-size: 14px;
        cursor: pointer;
        svg{
            width: 14px;
        }
    }
}
.assy{
    // margin-top: -40px;
    .el-table{
        width: 420px;
        max-height: 770px;
        overflow-x: hidden;
        overflow-y: auto;
        z-index: 9999;
        position: absolute;
        left: 13px;
        top: 5px;
        background: linear-gradient(135deg, #00032D 0%, #000C58 50%, #00032D 100%);

        // :deep(.el-table-row){
        //     background:rgba(71, 90, 219, .15) !important;
        // }
        :deep(tr:hover>td){
            background:rgba(71, 90, 219, .05) !important;
        }

        :deep(.el-table__header){
            border-bottom: 1px solid #475ADB;
            tr{
                background-color: transparent !important;
            }
            th.el-table__cell{
                background-color: transparent !important;
            }
            th.el-table__cell.is-leaf{
                border-bottom: none;
            }
        }
        :deep(.el-table__inner-wrapper::before){
            display: none;
        }

        
    }
    
}
</style>